const router = require("koa-router")();
const Mock = require("mockjs");

const { list } = Mock.mock({
  "list|100": [
    {
      title: "@ctitle",
      address: "@county(true)",
      "tags|2-8": [
        {
          "name|+1": [
            "改签",
            "小吃",
            "影城卡",
            "卷包",
            "IMAX",
            "杜比",
            "儿童听",
            "LPRO",
          ],
          "type|1": ["primary", "success", "danger", "warning"],
        },
      ],
      "price|20-100": 1,
      "disance|1-30": 1,
      "product|1": [
        "万达影城",
        "博纳国际影城",
        "耀菜成龙国际影城",
        "保利国际影城",
        "大地影院",
        "华联影城",
        "金逸影城",
        "CGV影城",
        "中影国际影城",
        "完美世界影城",
        "首都电影院",
      ],
    },
  ],
});

router.get("/list", (ctx) => {
  const { product } = ctx.request.query;
  if (product) {
     ctx.body = {
      code: 200,
      data: list.filter(v => v.product === product),
    };
  } else {
    ctx.body = {
      code: 200,
      data: list,
    };
  }
});

module.exports = router;
